// 数据
let users = [
  { id: 1, name: '张三', age: 10 },
  { id: 2, name: '李四', age: 11 },
  { id: 3, name: '王五', age: 12 },
  { id: 4, name: '赵六', age: 13 }
]

const all = () => users
const first = uid => users.find(({ id }) => id == uid)
const create = body => users.push(body)
const update = (uid, body) => {
  let index = users.findIndex(({ id }) => id == uid)
  users[index] = { ...users[index], ...body }
}
const destroy = uid => users.filter(({ id }) => id != uid)

module.exports = {
  all,
  first,
  create,
  update,
  destroy
}